/**
 * Created by Administrator on 2016/12/17.
 */
$(function(){
    init();
});
var str = location.search;
var json = {};
str = str.slice(1).split("&");
console.log(str);
for (var i = 0; i < str.length; i++) {
    var result = str[i].split("=");
    json[result[0]] = result[1];
}
console.log(json);
/****初始化表格数据*******/
function init(){//接收新增班组页面发送的数据 ，显示在新增工人页面表格中

    var str= localStorage.getItem("contractor");
   // console.log(str);
    $('#addWorkersTable').bootstrapTable({
        data:JSON.parse(str).data.list,
        success:function(data){
            console.log(data);
        },
        error:function(err){
            console.log(err);
        },
        onClickRow:function(row){
            sessionStorage.rowInfo=JSON.stringify(row);
            console.log(row);
           // json["id"]=parseInt(json.id);
            json["teamId"]=parseInt(json.teamId);
            json["userCode"]=row.userCode;
            json["workTypeId"]=10;
            console.log(JSON.stringify(json));

            $.ajax({
                type:"post",
                contentType:'application/json',
                dataType:"json",
                data:JSON.stringify(json),
                url:'http://192.168.59.3:8082/console/projectInfo/saveWorkItemsRelation',
                success:function(data){
                    console.log(data);
                    parent.layer.closeAll();
                },
                error:function(err){
                    console.log(err);
                }
            })

        }
    })
}
function responseHandler(res){
    //console.log(res);
    var needData = {
        rows: res.data.list,//只 输出data,内容不会显示 在页面内。必须 加上.list;
        total: res.data.total
    };
    return needData;
}
function indexFmt(val,row,index){
    /*var optionVar=$("table#addWorkersTable").data('bootstrap.table').options;
    var pageNum=optionVar.pageNumber;
    var pageSize=optionVar.pageSize;
    return (pageNum-1)*pageSize+index+1;*/
    return index+1;
}

function pjTableQuery(params){
    params["pageNum"] = (params.offset / params.limit) + 1;
    params.pageSize = params.limit;
    return params;

}
